package com.yykj.pay.server.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yykj.common.util.LocalStringUtil;
import com.yykj.pay.center.client.dto.ClientPayConfigDTO;
import com.yykj.pay.server.entity.ClientPayConfig;
import com.yykj.pay.server.repository.ClientPayConfigMapper;
import com.yykj.pay.server.service.ClientPayConfigService;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zengg
 * @since 2022-04-08
 */
@Service
@AllArgsConstructor
public class ClientPayConfigServiceImp extends ServiceImpl<ClientPayConfigMapper, ClientPayConfig> implements ClientPayConfigService {

    final ClientPayConfigMapper clientPayConfigMapper;
    @Override
    public Integer insertClientPayConfig(ClientPayConfig clientPayConfig) {
        clientPayConfig.setPayConfigId(LocalStringUtil.getUUID());
        return clientPayConfigMapper.insert(clientPayConfig);
    }

    @Override
    public ClientPayConfig getByClientId(String hospitalId) {
        return this.clientPayConfigMapper.findByClientId(hospitalId);
    }

    @Override
    public ClientPayConfigDTO get(String hospitalId) {
        ClientPayConfig clientPayConfig = this.clientPayConfigMapper.findByClientId(hospitalId);
        ClientPayConfigDTO clientPayConfigDTO = new ClientPayConfigDTO();
        BeanUtils.copyProperties(clientPayConfig, clientPayConfigDTO);
        return clientPayConfigDTO;
    }

}
